/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: StandardController
 * @Package com.rx.core.bean
 * @Description: 标准控制器
 * @author: 陈锦韬
 * @date: 2020\8\12 0012
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.core.controller;

import com.rx.core.base.RxBaseConstant;
import com.rx.core.base.RxBaseController;
import com.rx.core.base.RxBaseData;
import com.rx.core.mode.*;
import com.rx.core.service.StandardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author: Administrator
 * @Description: 标准控制器
 * @date: 2020\8\12 0012
 */
@RestController
@RequestMapping(RxBaseConstant.CONFIG_STANDARD_API)
@Slf4j
public class StandardController extends RxBaseController {

    @Autowired
    StandardService standardService;

    /**
     * 单表明细
     * @param data
     * @return
     */
    @PostMapping(value = SingleDetailHandlerContainer.URL_MODE)
    @ResponseBody
    public Object detail(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.detail(data);
    }

    /**
     * 单表列表
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object searchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.searchList(data);
    }

    /**
     * 单表分页
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SinglePageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object searchPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.searchPage(data);
    }

    /**
     * 逻辑删除
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleDeleteHandlerContainer.URL_MODE)
    @ResponseBody
    public Object delete(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.delete(data);
    }

    /**
     * 单表新增
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleInsertHandlerContainer.URL_MODE)
    @ResponseBody
    public Object insert(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.insert(data);
    }

    /**
     * 单表更新
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleUpdateHandlerContainer.URL_MODE)
    @ResponseBody
    public Object update(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.update(data);
    }
    /**
     * 记录数查询
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleCountHandlerContainer.URL_MODE)
    @ResponseBody
    public Object count(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.count(data);
    }

    /**
     * 最新一条记录
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleLatestHandlerContainer.URL_MODE)
    @ResponseBody
    public Object latest(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.latest(data);
    }

    /**
     * 统计
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleStatisHandlerContainer.URL_MODE)
    @ResponseBody
    public Object statis(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.statis(data);
    }

    /**
     * 批量插入
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleBatchInsertHandlerContainer.URL_MODE)
    @ResponseBody
    public Object batchInsert(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.batchInsert(data);
    }

    /**
     * 批量更新
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleBatchUpdateHandlerContainer.URL_MODE)
    @ResponseBody
    public Object batchUpdate(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.batchUpdate(data);
    }

    /**
     * 批量删除
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleBatchDeleteHandlerContainer.URL_MODE)
    @ResponseBody
    public Object batchDelete(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.batchDelete(data);
    }

    /**
     * 批量保存
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = SingleBatchSaveHandlerContainer.URL_MODE)
    @ResponseBody
    public Object batchSave(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.batchSave(data);
    }

    /**
     * 没有数据库活动
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = CommonNoDatabaseHandlerContainer.URL_MODE)
    @ResponseBody
    public Object noDatabase(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.noDatabase(data);
    }

    /**
     * 双表操作
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleInnerListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object innerSearchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.innerSearchList(data);
    }

    /**
     * 联合查询 (谨慎使用)
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleUnionInnerListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object unionSearchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.unionSearchList(data);
    }
    /**
     * 联合查询-分页 (谨慎使用)
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleUnionInnerPageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object unionSearchPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.unionSearchPage(data);
    }

    /**
     * 联合查询 (谨慎使用)
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleUnionLeftListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object unionLeftSearchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.unionLeftSearchList(data);
    }
    /**
     * 联合查询-分页 (谨慎使用)
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleUnionLeftPageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object unionLeftSearchPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.unionLeftSearchPage(data);
    }

    /**
     * 双表左连接
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleLeftListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object leftSearchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.leftSearchList(data);
    }

    /**
     * 双表分页
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleInnerPageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object innerSearchPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.innerSearchPage(data);
    }

    /**
     * 双表左连接分页
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleLeftPageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object leftSearchPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.leftSearchPage(data);
    }

    /**
     * 双表插入
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleInsertHandlerContainer.URL_MODE)
    @ResponseBody
    public Object doubleInsert(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.doubleInsert(data);
    }

    /**
     * 拷贝插入
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = DoubleCopyHandlerContainer.URL_MODE)
    @ResponseBody
    public Object copyInsert(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.copyInsert(data);
    }

    /**
     * 三表操作
     * @param data
     * @param form
     * @return
     */
    @PostMapping(value = ThreeInnerListHandlerContainer.URL_MODE)
    @ResponseBody
    public Object threeInnerSearchList(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.threeInnerSearchList(data);
    }

    @PostMapping(value = ThreeInnerLeftPageHandlerContainer.URL_MODE)
    @ResponseBody
    public Object threeInnerLeftPage(@Valid  @RequestBody RxBaseData data, @PathVariable String form){
        return standardService.threeInnerLeftPage(data);
    }
}
